package at.fhv.gis.db;

import java.sql.SQLException;

import javax.naming.OperationNotSupportedException;

import at.fhv.gis.util.Server;

public class DbProvider {
	private static DbManager INSTANCE;

	public static DbManager getInstance()
			throws OperationNotSupportedException, ClassNotFoundException,
			SQLException {
		if (INSTANCE == null) {
			if ("postgres".equals(Server.config.getString("db"))) {
				INSTANCE = new DbManagerPostgres();
			} else if ("sqlite".equals(Server.config.getString("db"))) {
				INSTANCE = new DbManagerSqlite();
			} else {
				throw new OperationNotSupportedException();
			}
		}

		return INSTANCE;
	}
}
